#pragma once

#include <gofcl_usbfs_r.h>

typedef enum {
	USBFS_DIEP0TFLEN = 0x100,
	USBFS_DIEP1TFLEN = 0x104,
	USBFS_DIEP2TFLEN = 0x108,
	USBFS_DIEP3TFLEN = 0x10C,
} usbfs_dieptflen_re;

typedef struct {
	u32_s IEPTXRSAR : 16;
	u32_s IEPTXFD : 16;
} usbfs_dieptflen_s;

_Static_assert(sizeof(usbfs_dieptflen_s) == 4,
	       "Struct usbfs_dieptflen_s defined error!");

static inline u32_s usbfs_get_dieptflen_q(usbfs_dieptflen_re re) {
	return USBFS_Q + re;
}

static inline void usbfs_wreg_dieptflen_s(usbfs_dieptflen_re re,
					  usbfs_dieptflen_s deptflen) {
	union {
		usbfs_dieptflen_s d;
		u32_s u;
	} du = {
		.d = deptflen,
	};
	u32_s reg_q = usbfs_get_dieptflen_q(re);
	wreg(reg_q, du.u);
}
